<!--查看应聘者，米娜事，考核，录用-->
<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in" ref="dialogBox">
      <div class="cornerComment-in-title">
        <span>{{Number(typeData)==1?'选择设备':'选择设备类目'}}</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody">
        <!--本体列表，数据 -->
        <div class="table-body">
          <div class="table-body-box">
            <el-table
              ref="multipleTable"
              :data="arryList"
              :height="tableHeight"
              tooltip-effect="dark">
              <el-table-column
                label="序列号"
                align="center"
                prop="deviceId"
                v-if="Number(typeData)==1"
                :key="1">
              </el-table-column>
              <el-table-column
                label="序列号"
                align="center"
                prop="id"
                v-if="Number(typeData)==2"
                :key="2">
              </el-table-column>
              <el-table-column
                label="名称"
                align="center"
                prop="name"
                :key="3">
              </el-table-column>
              <el-table-column
                label="操作"
                align="center"
                width="80"
                :key="13">
                <template slot-scope="scope">
                  <el-button size="small" @click="showDetail(scope.row)">选择</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
        <!--工具条 分页-->
        <el-col :span="24" class="toolbarLine">
          <pagination
            v-show="total>0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </el-col>
      </div>
      <div class="cornerComment-in-footer">
        <el-button type="primary" @click="closePOpup" size="small">返回</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import {listDevice} from "@/api/system/device";
import {listCategory} from "@/api/system/category";

export default {
  props: ['visible', 'typeData'], // recruitId 招聘id
  components: {},
  data() {
    return {
      dialogVisible: false,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        deviceId: null,
        pushTopic: null,
        subTopic: null,
        isOnline: null
      },
      total: 0,
      arryList: [],
      tableHeight: 0
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if (this.visible) {
        let n = this;
        this.$nextTick(() => {
          let height = n.$refs.dialogBox.offsetHeight;
          n.tableHeight = height - (51 + 50 + 60 + 31)
        })
        this.getList()
      } else {
        this.arryList = []
        this.total = 0
        this.queryParams = {
          pageNum: 1,
          pageSize: 10,
        }
      }
    }
  },
  created() {

  },
  methods: {
    /** 查询设备管理列表 */
    getList() {
      this.loading = true;
      if (Number(this.typeData) === 1) {
        listDevice(this.queryParams).then(response => {
          this.arryList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      } else {
        listCategory(this.queryParams).then(response => {
          this.arryList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      }
    },
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
    showDetail(item) {
      this.$emit('getOptionData', JSON.parse(JSON.stringify(item)))
      this.closePOpup()
    }
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 50%;
  height: 70%;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 10px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}

.toolbarLine {
  text-align: center;
}
</style>


